package org.kingtop.mybatis.persistence.metamodel;

/**
 * 数据类型key，用于DbTypeEnum，方便查询
 *
 * @author 陈金波
 * @date 2018年1月3日 下午6:40:12
 * @Copyright: 2018 chen jinbo. All rights reserved.
 */
public class DbTypeKey {

	/**
	 * 数据库类型
	 */
	private String dbType;

	/**
	 * java类型
	 */
	private Class<?> javaType;

	/**
	 * 
	 * 
	 * @param dbType
	 *            数据库类型
	 * @param javaType
	 *            java类型
	 */
	public DbTypeKey(String dbType, Class<?> javaType) {
		super();
		this.dbType = dbType;
		this.javaType = javaType;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((dbType == null) ? 0 : dbType.hashCode());
		result = prime * result + ((javaType == null) ? 0 : javaType.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
            return false;
        }
		if (getClass() != obj.getClass()) {
            return false;
        }
		DbTypeKey other = (DbTypeKey) obj;
		if (dbType == null) {
			if (other.dbType != null) {
                return false;
            }
		} else if (!dbType.equals(other.dbType)) {
            return false;
        }
		if (javaType == null) {
			if (other.javaType != null) {
                return false;
            }
		} else if (!javaType.equals(other.javaType)) {
            return false;
        }
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "DbTypeKey [dbType=" + dbType + ", javaType=" + javaType + "]";
	}

	/**
	 * @return the dbType
	 */
	public String getDbType() {
		return dbType;
	}

	/**
	 * @param dbType
	 *            the dbType to set
	 */
	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

	/**
	 * @return the javaType
	 */
	public Class<?> getJavaType() {
		return javaType;
	}

	/**
	 * @param javaType
	 *            the javaType to set
	 */
	public void setJavaType(Class<?> javaType) {
		this.javaType = javaType;
	}

}
